#include <iostream>
#include <stdexcept>
#include <windows.h> // Windows 系统特有，设置控制台编码
using namespace std;

class Draw {
private:
    int height;

public:
    Draw(int h) {
        if (h <= 3) {
            throw invalid_argument("高度必须大于3！");
        }
        height = h;
    }

    void DrawTriangle() {
        cout << "绘制三角形：" << endl;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < height - i - 1; j++) cout << " ";
            for (int j = 0; j < 2 * i + 1; j++) cout << "*";
            cout << endl;
        }
    }

    void DrawRectangle() {
        cout << "绘制矩形：" << endl;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < 2 * height; j++) cout << "* ";
            cout << endl;
        }
    }

    void DrawSquare() {
        cout << "绘制正方形：" << endl;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < height; j++) cout << "* ";
            cout << endl;
        }
    }

    void DrawParallelogram() {
        cout << "绘制平行四边形：" << endl;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < height - i - 1; j++) cout << " ";
            for (int j = 0; j < height; j++) cout << "*";
            cout << endl;
        }
    }
};

int main() {
    SetConsoleOutputCP(65001); // 设置控制台输出为 UTF-8 编码

    try {
        Draw draw(5);

        draw.DrawTriangle();
        draw.DrawRectangle();
        draw.DrawSquare();
        draw.DrawParallelogram();
    } catch (const exception &e) {
        cerr << "错误: " << e.what() << endl;
    }

    return 0;
}
